<?php

namespace app\admin\model;

use think\Model;

class Speech extends Model
{
    // 表名
    protected $name = 'speech';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'int';

    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = 'updatetime';
    
    // 追加属性
    protected $append = [
        'industry_text'
    ];
    

    
    public function getIndustryList()
    {
        return ['finance' => __('Industry finance'),'house' => __('Industry house'),'edu' => __('Industry edu'),'ad' => __('Industry ad'),'other' => __('Industry other')];
    }     


    public function getIndustryTextAttr($value, $data)
    {        
        $value = $value ? $value : $data['industry'];
        $list = $this->getIndustryList();
        return isset($list[$value]) ? $list[$value] : '';
    }




    public function admin()
    {
        return $this->belongsTo('Admin', 'admin_id', 'id', [], 'LEFT')->setEagerlyType(0);
    }
}
